/*
 Copyright 2008 Under Dusken

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
 */

package org.dyndns.anderlin.jmplayer.service;

import org.dyndns.anderlin.jmplayer.model.JmplayerObject;

/**
 * Service offering generic methods that make sense on all PegadiObjects.
 * getAllEntities is not included since the ordering is important.
 */
public interface GenericService<T extends JmplayerObject> {

    /**
     * Gets a pegadi object
     *
     * @param ID is the objects ID
     * @return the object, null if none found
     */
    public T getEntity(Long ID);

    /**
     * Save changes or save a new pegadi object
     *
     * @param entity is the object to persist/merge
     * @return the object as it was saved. ID is added if new, version updated
     */
    public T saveOrUpdate(T entity);

    /**
     * Delete a pegadi object
     *
     * @param entity to remove
     * @return true if the entity was deleted
     */
    public boolean remove(T entity);     /**
     * Gets the object based on the field external_id
     *
     * @param ID
     *            is the id from the system the entity was imported from
     * @return the lazy object if found
     */
    public T getEntityByExternalID(Long ID);

}
